package com.sugou.services.support;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.sugou.dao.support.Dao;
import com.sugou.model.core.IdEntity;

@org.springframework.stereotype.Service("baseService")
@Transactional(readOnly=true)
public class BaseService<E extends Serializable> implements Service<E> {
	private static final long serialVersionUID = -2735247705037765073L;
	@Resource(name="baseDao")
	private Dao<E> dao;
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=Throwable.class)
	public Number save(E entity) {
		return this.dao.save(entity);
	}

	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=Throwable.class)
	public Number remove(E entity) {
		
		return this.dao.remove(entity);
	}

	public List<E> search(CharSequence stat) {
		return this.dao.list(stat);
	}

	public Dao<E> getDao() {
		return dao;
	}

	public void setDao(Dao<E> dao) {
		this.dao = dao;
	}

	public IdEntity getEntity(Class cls, Serializable id) {
		return this.dao.getEntity(cls, id);
	}

}
